package com.wlc.thread.demo02;

/**
 * @author 王立朝 wanglichao@champion-credit.com
 * @description 测试多线程
 * @date 2021-07-15 08:27
 */
public class TestThreadDemo {

    public static void method01() {
        try {
            new MyThreadDemo("第一个线程").start();
            Thread.sleep(5000);

        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    public static void method03(){
        new MyThreadDemo("第二个线程").start();
    }

    public static void method02() {
        new Thread() {
            @Override
            public void run() {
                System.out.println("我是匿名类创建的多线程方法");
            }
        }.start();
    }

    /**
     * 使用Runnable 方式启动线程
     */
    public static void method04(){
        Thread thread = new Thread(new MyRunnableDemo());
        thread.start();
        thread.interrupt();
    }

    public static void main(String[] args) {
        method04();
    }
}
